﻿#define _CRT_SECURE_NO_WARNINGS 1


//两个队列
class MyStack {
public:
    MyStack()
    {}

    void push(int x)
    {
        queue2.push(x);
        while (!queue1.empty())
        {
            queue2.push(queue1.front());
            queue1.pop();
        }
        swap(queue1, queue2);
    }

    int pop()
    {
        int n = queue1.front();
        queue1.pop();
        return n;
    }

    int top()
    {
        return queue1.front();
    }

    bool empty()
    {
        return queue1.empty();
    }
private:
    queue<int> queue1;
    queue<int> queue2;
};


//一个队列
class MyStack {
public:
    MyStack()
    {}

    void push(int x)
    {
        int n = queue1.size();
        queue1.push(x);
        for (int i = 0; i < n; ++i)
        {
            queue1.push(queue1.front());
            queue1.pop();
        }
    }

    int pop()
    {
        int n = queue1.front();
        queue1.pop();
        return n;
    }

    int top()
    {
        return queue1.front();
    }

    bool empty()
    {
        return queue1.empty();
    }
private:
    queue<int> queue1;
};



